<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>5.9 幸运转盘</title>
</head>

<body>
    <script>
        var win = 0;
        var total = 0;
        var isWin = false;
        var winRate = 0;
        var numStr = '';

        function luck() {
            var num = 0;
            numStr = '';
            isWin = false;
            for (var i = 0; i < 3; i++) {
                num = Math.floor(Math.random() * 9) + 1;
                numStr += num;
                if (num == 8) {
                    isWin = true;
                }
            }
            if (isWin) {
                win++;
            }
            total++;
            winRate =(win/total)*100 + "%";
        }

        while(true){
            luck();
            if(!confirm(numStr + '\n' +(isWin ? "赢" : "输") + "\n胜率"  + winRate + ",继续吗?")){
                break;
            }
            
            // if(confirm())
        }

    
    </script>
</body>

</html>